package com.nextplus.housetolet.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.nextplus.housetolet.domain.User;

/**
 * 用户管理主页
 * 
 * @author didi
 *
 * 创建时间：2013-1-8
 *
 */
@Controller
public class MainController extends BaseController {
	
	@RequestMapping(value = "/user/{userId}", method = RequestMethod.GET) 
	public String userMainPage(
			@PathVariable("userId") Long userId, 
			HttpSession session, 
			ModelMap modelMap) {
		User user = (User) session.getAttribute("user");
		if(user == null || user.getId() != userId) {
			return "redirect:/login";
		}
		modelMap.addAttribute(PAGE_PATH, "content/main");
		return "layout";
	}

}
